package com.yyf.springboot2.common;

/**
 * 1xx 信息提示
 *
 *104:系统操作成功,但是需要给前端提示错误信息
 * 2xx 成功
 * 3xx 重定向
 * 4xx 客户端错误   参数错误
 * 5xx 服务器错误
 *
 *
 * 100 未知错误
 * 104 参数不能为空
 * 200成功
 * 500系统错误
 * 501 未知错误
 *
 */
public class ResultBean {

    // 响应业务状态
    private Integer status;

    // 响应消息
    private String msg;

    // 响应中的数据
    private Object data;
    
    private String ok;	// 不使用

    public static ResultBean build(Integer status, String msg, Object data) {
        return new ResultBean(status, msg, data);
    }

    public static ResultBean ok(Object data) {
        return new ResultBean(data);
    }

    public static ResultBean ok() {
        return new ResultBean(null);
    }
    
    public static ResultBean errorMsg(String msg) {
        return new ResultBean(500, msg, null);
    }
    
    public static ResultBean errorMap(Object data) {
        return new ResultBean(501, "error", data);
    }
    
    public static ResultBean errorTokenMsg(String msg) {
        return new ResultBean(502, msg, null);
    }
    
    public static ResultBean errorException(String msg) {
        return new ResultBean(555, msg, null);
    }

    public ResultBean() {

    }

    public ResultBean(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public ResultBean(Object data) {
        this.status = 200;
        this.msg = "OK";
        this.data = data;
    }

    public Boolean isOK() {
        return this.status == 200;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

	public String getOk() {
		return ok;
	}

	public void setOk(String ok) {
		this.ok = ok;
	}

}
